package com.example.chinesenation.Handler;

import com.baomidou.mybatisplus.core.MybatisParameterHandler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.sql.Timestamp;

/**
 * @author sakuraFallingDown
 * @version 1.0
 * @date 2021/1/11 14:29
 */
@Configuration
public class MybatisPlusHandler implements MetaObjectHandler {//自动填充字段
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime",new Timestamp(System.currentTimeMillis()),metaObject);
        this.setFieldValByName("updateTime",new Timestamp(System.currentTimeMillis()),metaObject);
    }
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime",new Timestamp(System.currentTimeMillis()),metaObject);
    }
}